####Operations
* Cluster each object individually * Crudely identify clusters in the DMSO object * Transfer cluster identities to the ava, ory, and combo objects

#####Data Import Options - File naming importDate - select the creation date for the desired object Filtering - build in ability to process differently filtered objects in parallel + nofilt: objects include all cells that pass min/max counts, max % mitochondria + filtered: objects filtered to have similar numbers of cells, counts/cell

#####Regression Options (in each object) * regress - start from preprocessed objects + noregress + regress.CC - regress on cell cycle - probably not the best option as it removes any cell cycle information that may be important for differentiating cells + regress.diff - regress on the difference in cell cycle values; per Seurat notations, it preserves cell cycle information relevant to development

Set up libraries and directories

Cluster individual experiments

## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 1657
## Number of edges: 52048
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8081
## Number of communities: 11
## Elapsed time: 0 seconds
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 1657
## Number of edges: 52895
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8044
## Number of communities: 9
## Elapsed time: 0 seconds
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 1657
## Number of edges: 52344
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8082
## Number of communities: 9
## Elapsed time: 0 seconds
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 2740
## Number of edges: 87365
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8156
## Number of communities: 9
## Elapsed time: 0 seconds
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 2740
## Number of edges: 87636
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8135
## Number of communities: 10
## Elapsed time: 0 seconds
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 2740
## Number of edges: 87553
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8152
## Number of communities: 10
## Elapsed time: 0 seconds
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 3379
## Number of edges: 109379
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8181
## Number of communities: 11
## Elapsed time: 0 seconds
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 3379
## Number of edges: 109935
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8124
## Number of communities: 11
## Elapsed time: 0 seconds
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 3379
## Number of edges: 110141
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8163
## Number of communities: 11
## Elapsed time: 0 seconds
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 1859
## Number of edges: 60017
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.7847
## Number of communities: 9
## Elapsed time: 0 seconds
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 1859
## Number of edges: 60607
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.7802
## Number of communities: 9
## Elapsed time: 0 seconds
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
## 
## Number of nodes: 1859
## Number of edges: 60263
## 
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.7841
## Number of communities: 9
## Elapsed time: 0 seconds

Plot Individual Clusters

###Sankey Plots to illustrate clustering differences

Identify dmso Clusters (loosely!)

CD34/SOX4/ERG are stem cell genes one end of the dog bone
CD14, ITGAX, LYZ are mature monocyte genes at the other end of the dog bone

Note: Will need to redo this in filtered objects

## Warning: Using `as.character()` on a quosure is deprecated as of rlang 0.3.0.
## Please use `as_label()` or `as_name()` instead.
## This warning is displayed once per session.

Assign DMSO cluster names

Transfer Cluster Labels

## Performing PCA on the provided reference using 2170 features as input.
## Projecting PCA
## Warning in DietSeurat(object = reference, features = features): No features
## found in assay 'ADT', removing...
## Warning in DietSeurat(object = query, features = features): No features found in
## assay 'ADT', removing...
## Finding neighborhoods
## Finding anchors
##  Found 4977 anchors
## Filtering anchors
##  Retained 4721 anchors
## Finding integration vectors
## Finding integration vector weights
## Predicting cell labels
## Performing PCA on the provided reference using 2142 features as input.
## Projecting PCA
## Warning in DietSeurat(object = reference, features = features): No features
## found in assay 'ADT', removing...

## Warning in DietSeurat(object = reference, features = features): No features
## found in assay 'ADT', removing...
## Finding neighborhoods
## Finding anchors
##  Found 5238 anchors
## Filtering anchors
##  Retained 4904 anchors
## Finding integration vectors
## Finding integration vector weights
## Predicting cell labels
## Performing PCA on the provided reference using 2079 features as input.
## Projecting PCA
## Warning in DietSeurat(object = reference, features = features): No features
## found in assay 'ADT', removing...

## Warning in DietSeurat(object = reference, features = features): No features
## found in assay 'ADT', removing...
## Finding neighborhoods
## Finding anchors
##  Found 4034 anchors
## Filtering anchors
##  Retained 3936 anchors
## Finding integration vectors
## Finding integration vector weights
## Predicting cell labels
## Warning: Keys should be one or more alphanumeric characters followed by an
## underscore, setting key from sct.cc_ to sctcc_
## Warning: Keys should be one or more alphanumeric characters followed by an
## underscore, setting key from sct.cc_ to sctcc_
## Performing PCA on the provided reference using 2170 features as input.
## Projecting PCA
## Warning in DietSeurat(object = reference, features = features): No features
## found in assay 'ADT', removing...
## Warning in DietSeurat(object = query, features = features): No features found in
## assay 'ADT', removing...
## Finding neighborhoods
## Finding anchors
##  Found 4833 anchors
## Filtering anchors
##  Retained 4584 anchors
## Finding integration vectors
## Finding integration vector weights
## Predicting cell labels
## Warning: Keys should be one or more alphanumeric characters followed by an
## underscore, setting key from sct.cc_ to sctcc_
## Warning: Keys should be one or more alphanumeric characters followed by an
## underscore, setting key from sct.cc_ to sctcc_
## Performing PCA on the provided reference using 2142 features as input.
## Projecting PCA
## Warning in DietSeurat(object = reference, features = features): No features
## found in assay 'ADT', removing...
## Warning in DietSeurat(object = query, features = features): No features found in
## assay 'ADT', removing...
## Finding neighborhoods
## Finding anchors
##  Found 5142 anchors
## Filtering anchors
##  Retained 4836 anchors
## Finding integration vectors
## Finding integration vector weights
## Predicting cell labels
## Warning: Keys should be one or more alphanumeric characters followed by an
## underscore, setting key from sct.cc_ to sctcc_
## Warning: Keys should be one or more alphanumeric characters followed by an
## underscore, setting key from sct.cc_ to sctcc_
## Performing PCA on the provided reference using 2079 features as input.
## Projecting PCA
## Warning in DietSeurat(object = reference, features = features): No features
## found in assay 'ADT', removing...
## Warning in DietSeurat(object = query, features = features): No features found in
## assay 'ADT', removing...
## Finding neighborhoods
## Finding anchors
##  Found 3948 anchors
## Filtering anchors
##  Retained 3836 anchors
## Finding integration vectors
## Finding integration vector weights
## Predicting cell labels
## Warning: Keys should be one or more alphanumeric characters followed by an
## underscore, setting key from sct.diff_ to sctdiff_
## Warning: Keys should be one or more alphanumeric characters followed by an
## underscore, setting key from sct.diff_ to sctdiff_
## Performing PCA on the provided reference using 2170 features as input.
## Projecting PCA
## Warning in DietSeurat(object = reference, features = features): No features
## found in assay 'ADT', removing...
## Warning in DietSeurat(object = query, features = features): No features found in
## assay 'ADT', removing...
## Finding neighborhoods
## Finding anchors
##  Found 4956 anchors
## Filtering anchors
##  Retained 4747 anchors
## Finding integration vectors
## Finding integration vector weights
## Predicting cell labels
## Warning: Keys should be one or more alphanumeric characters followed by an
## underscore, setting key from sct.diff_ to sctdiff_
## Warning: Keys should be one or more alphanumeric characters followed by an
## underscore, setting key from sct.diff_ to sctdiff_
## Performing PCA on the provided reference using 2142 features as input.
## Projecting PCA
## Warning in DietSeurat(object = reference, features = features): No features
## found in assay 'ADT', removing...
## Warning in DietSeurat(object = query, features = features): No features found in
## assay 'ADT', removing...
## Finding neighborhoods
## Finding anchors
##  Found 5183 anchors
## Filtering anchors
##  Retained 4831 anchors
## Finding integration vectors
## Finding integration vector weights
## Predicting cell labels
## Warning: Keys should be one or more alphanumeric characters followed by an
## underscore, setting key from sct.diff_ to sctdiff_
## Warning: Keys should be one or more alphanumeric characters followed by an
## underscore, setting key from sct.diff_ to sctdiff_
## Performing PCA on the provided reference using 2079 features as input.
## Projecting PCA
## Warning in DietSeurat(object = reference, features = features): No features
## found in assay 'ADT', removing...
## Warning in DietSeurat(object = query, features = features): No features found in
## assay 'ADT', removing...
## Finding neighborhoods
## Finding anchors
##  Found 3996 anchors
## Filtering anchors
##  Retained 3887 anchors
## Finding integration vectors
## Finding integration vector weights
## Predicting cell labels

Compare transferred vs. native clusters

Save the data

## [1] "nofilt objects:  Saving scaled/normalized/regressed data in individual objects in aml_eto.indivClustSO.nofilt.2020-11-04.rds"
## R version 4.0.2 (2020-06-22)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Catalina 10.15.7
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] dplyr_1.0.2       patchwork_1.0.1   networkD3_0.4     knitr_1.30       
## [5] ggplot2_3.3.2     data.table_1.13.0 Seurat_3.2.2     
## 
## loaded via a namespace (and not attached):
##  [1] nlme_3.1-149          matrixStats_0.57.0    RcppAnnoy_0.0.16     
##  [4] RColorBrewer_1.1-2    httr_1.4.2            sctransform_0.3      
##  [7] tools_4.0.2           R6_2.4.1              irlba_2.3.3          
## [10] rpart_4.1-15          KernSmooth_2.23-17    uwot_0.1.8           
## [13] mgcv_1.8-33           lazyeval_0.2.2        colorspace_1.4-1     
## [16] withr_2.3.0           tidyselect_1.1.0      gridExtra_2.3        
## [19] compiler_4.0.2        plotly_4.9.2.1        labeling_0.3         
## [22] scales_1.1.1          lmtest_0.9-38         spatstat.data_1.4-3  
## [25] ggridges_0.5.2        pbapply_1.4-3         spatstat_1.64-1      
## [28] goftest_1.2-2         stringr_1.4.0         digest_0.6.25        
## [31] spatstat.utils_1.17-0 rmarkdown_2.4         pkgconfig_2.0.3      
## [34] htmltools_0.5.0       fastmap_1.0.1         htmlwidgets_1.5.2    
## [37] rlang_0.4.7           shiny_1.5.0           farver_2.0.3         
## [40] generics_0.0.2        zoo_1.8-8             jsonlite_1.7.1       
## [43] ica_1.0-2             magrittr_1.5          Matrix_1.2-18        
## [46] Rcpp_1.0.5            munsell_0.5.0         abind_1.4-5          
## [49] reticulate_1.16       lifecycle_0.2.0       stringi_1.5.3        
## [52] yaml_2.2.1            MASS_7.3-53           Rtsne_0.15           
## [55] plyr_1.8.6            grid_4.0.2            parallel_4.0.2       
## [58] listenv_0.8.0         promises_1.1.1        ggrepel_0.8.2        
## [61] crayon_1.3.4          deldir_0.1-29         miniUI_0.1.1.1       
## [64] lattice_0.20-41       cowplot_1.1.0         splines_4.0.2        
## [67] tensor_1.5            pillar_1.4.6          igraph_1.2.5         
## [70] future.apply_1.6.0    reshape2_1.4.4        codetools_0.2-16     
## [73] leiden_0.3.3          glue_1.4.2            evaluate_0.14        
## [76] vctrs_0.3.4           png_0.1-7             httpuv_1.5.4         
## [79] gtable_0.3.0          RANN_2.6.1            purrr_0.3.4          
## [82] polyclip_1.10-0       tidyr_1.1.2           future_1.19.1        
## [85] xfun_0.18             rsvd_1.0.3            mime_0.9             
## [88] xtable_1.8-4          later_1.1.0.1         survival_3.2-7       
## [91] viridisLite_0.3.0     tibble_3.0.3          cluster_2.1.0        
## [94] globals_0.13.0        fitdistrplus_1.1-1    ellipsis_0.3.1       
## [97] ROCR_1.0-11